package com.tomorrow.weather.ui;

import com.tomorrow.weather.application.AppConfig;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

public class LogoActivity extends Activity
{
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		// this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		// this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
		// WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.logo);
		AlphaAnimation animation = new AlphaAnimation(1.0f, 1.0f);
		animation.setDuration(1000);

		ImageView img_logo = (ImageView) this.findViewById(R.id.img_logo);
		img_logo.setAnimation(animation);
		animation.setAnimationListener(new AnimationListener()
		{

			@Override
			public void onAnimationStart(Animation animation)
			{

			}

			@Override
			public void onAnimationRepeat(Animation animation)
			{

			}

			@Override
			public void onAnimationEnd(Animation animation)
			{
				SharedPreferences preferences = AppConfig
						.getSharedPreferences(LogoActivity.this);
				boolean fisrtLogin = preferences.getBoolean("firstLogin", true);
				if (fisrtLogin)
				{
					Intent intent = new Intent(LogoActivity.this,
							AddCityActivity.class);
					startActivity(intent);
				}
				else
				{
					Intent intent = new Intent(LogoActivity.this,
							MainActivity.class);
					startActivity(intent);
				}

				LogoActivity.this.finish();
			}
		});

	}
}
